import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextInt();
        }
        int target= in.nextInt();
        System.out.println(Arrays.toString(twoSum(arr, target)));
    }
    public static int[] twoSum(int[] nums, int target) {
        //将当前数之前的数全部放入哈希表中
        HashMap<Integer,Integer> hashMap = new HashMap<>();//<value,index>
        hashMap.put(nums[0],0);//直接跳过第一个数,从第二个开始
        int[] arr = new int[2];
        for (int i = 1; i < nums.length ; i++) {
            int flag = target-nums[i];//要找的值
            Integer result = hashMap.get(flag);
            if(result!=null){
                arr[0] = i;
                arr[1] = result;
                break;
            }
            hashMap.put(nums[i], i);
        }
        return arr;
    }
}
